<template>
  <div class="radiotype-wrap f-cb">
    <div class="new">
      <div class="u-title f-cb">
        <h3><span class="f-ff2">优秀新电台</span></h3>
      </div>
      <ul class="m-rdilist f-cb">
        <li v-for="item in newRadio" :key="item.id">
          <a href="javascript:;" @click="goRoute('/find/djradio/',item.id)" class="u-cover u-cover-rdi2">
            <img :src="item.picUrl" alt="" />
          </a>
          <h3 class="f-fs2">
            <a href="javascript:;" @click="goRoute('/find/djradio/',item.id)" class="s-fc1" :title="item.name">{{
              item.name
            }}</a>
          </h3>
          <p class="f-thide2 s-fc4">{{ item.rcmdtext }}</p>
        </li>
      </ul>
    </div>
    <div id="allradios" class="rdimore">
      <div class="u-title f-cb">
        <h3><span class="f-ff2">电台排行榜</span></h3>
        <div class="tab tab-r">
          <a data-action="order" href="javascript:void(0);" class="z-sel"
            >最热电台</a
          >
        </div>
      </div>
      <AllRadio :id="id" :offset="offset"></AllRadio>
      <div class="u-page" @click="gopage()">
        <el-pagination background layout="prev, pager, next" :total="340">
        </el-pagination>
      </div>
    </div>
  </div>
</template>
<script>
import AllRadio from "@/components/AllRadio";
export default {
  data: () => ({
    id: 11111,
    newRadio: [],
    offset: 0,
  }),
  created() {
    this.id = this.$route.params.id;
    // console.log(this.$route);
    this.getRadioListByType(this.id);
  },
  updated() {
    this.id = this.$route.params.id;
    // console.log(this.$route);
    this.getRadioListByType(this.id);
  },
  methods: {
    async getRadioListByType(id) {
      const {
        data: { djRadios },
      } = await this.Api.wjwApi.getRadioListByType(id);
      this.newRadio = djRadios.slice(0, 5);
      // console.log(this.newRadio);
    },
    gopage() {
      const n = document.querySelector(".el-pagination .active").textContent;
      this.offset = (n - 1) * 30;
      // console.log(n);
      // console.log(this.id, this.offset);
    },
  },
  components: {
    AllRadio,
  },
};
</script>
<style lang="less">
.u-title {
  height: 40px;
  border-bottom: 2px solid #c20c0c;
  h3 {
    float: left;
    font-size: 24px;
    font-weight: normal;
    .f-ff2 {
      font-family: "Microsoft Yahei", Arial, Helvetica, sans-serif;
    }
  }
}
.f-cb:after {
  clear: both;
  content: ".";
  display: block;
  height: 0;
  visibility: hidden;
}
a {
  text-decoration: none;
}
em {
  font-style: normal;
}
li {
  list-style: none;
}
.f-fl {
  float: left;
}
.f-fr {
  float: right;
}

.radiotype-wrap {
  padding: 0 40px;
  .m-rdilist {
    margin: 16px 0 0 -37px;
    li {
      float: left;
      width: 150px;
      margin-left: 37px;
      .u-cover-rdi2 {
        width: 150px;
        height: 150px;
      }
      .u-cover {
        position: relative;
        display: block;
        img {
          display: block;
          width: 100%;
          height: 100%;
        }
      }
      .u-cover-rdi {
        width: 120px;
        height: 120px;
      }
    }
    h3 {
      margin: 13px 0 6px;
      line-height: 16px;
      font-size: 14px;
      font-weight: normal;
      .s-fc1 {
        color: #333;
      }
    }
    .f-thide2,
    .f-thide3 {
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .s-fc4,
    a.s-fc4:hover {
      color: #999;
    }
    p {
      line-height: 18px;
      font-size: 12px;
    }
  }
  .rdimore {
    margin-top: 35px;
    .u-title .tab {
      float: left;
      margin: 12px 0 0 20px;
    }
    .u-title .tab-r {
      float: right;
      a {
        color: #c20c0c;
        font-size: 12px;
      }
    }
  }
  .rdilist {
    margin-left: -30px;
    li {
      float: left;
      width: 435px;
      height: 120px;
      margin-left: 30px;
      _margin-left: 15px;
      padding: 20px 0;
      border-bottom: 1px solid #e7e7e7;
      .cvr {
        margin-right: -200px;
      }
      .u-cover-rdi {
        width: 120px;
        height: 120px;
      }
      .u-cover {
        position: relative;
        display: block;
        img {
          display: block;
          width: 100%;
          height: 100%;
        }
      }
      .cnt {
        margin-left: 140px;
        h3 {
          height: 64px;
          margin: 0;
          line-height: 64px;
          a {
            display: inline-block;
            line-height: normal;
            vertical-align: middle;
            color: #333;
            font-size: 18px;
          }
        }
        .note {
          margin-bottom: 6px;
          line-height: 20px;
          .u-icn,
          .u-icn2,
          .u-icn3 {
            display: inline-block;
            overflow: hidden;
            vertical-align: middle;

            background: url("../../../../../assets/wjwimgs/icon.png") no-repeat 0
              9999px;
          }
          .u-icn-27 {
            width: 14px;
            height: 15px;
            background-position: -50px -300px;
          }
          .sep {
            margin-left: 5px;
            margin-right: 4px;
            word-wrap: break-word;
            word-break: break-word;
            white-space: normal;
            font-size: 12px;
            color: #333;
          }
          .u-icn2 {
            background: url("../../../../../assets/wjwimgs/icon2.png") no-repeat 0
              9999px;
          }
          .u-icn2-music2 {
            width: 12px;
            height: 13px;
            background-position: -110px -190px;
          }
        }
        .s-fc4 {
          color: #999;
          font-size: 12px;
        }
      }
    }
  }
  div.u-page {
    margin: 20px 0;
    text-align: center;
  }
  .el-pagination.is-background .el-pager li:not(.disabled).active {
    background-color: #c20c0c;
    color: #fff;
  }
  .el-pager li.active {
    color: #c20c0c;
    cursor: default;
  }
}
</style>
